import { OnInit, Component, ViewChild } from '@angular/core';
import { AcademyDTO } from 'src/app/project/model/icm/icm-base/academy/academy.dto';
import { AcademyService } from 'src/app/project/service/icm/icm-base/academy/academy.service';
import { ProfessionListComponent } from './profession-list.component';

@Component({
  selector: 'app-profession-view',
  templateUrl: './profession-view.component.html',
  styles: [],
})
export class ProfessionViewComponent implements OnInit {
  constructor(private academyService: AcademyService) {}

  @ViewChild('professionListComponent', { static: false })
  professionListComponent: ProfessionListComponent;

  /**
   * 条件查询参数
   */
  queryParams = {
    code: null,
    name: null,
    academyId: null,
  };

  /**
   * 学院下拉
   */
  // academyList: Array<AcademyDTO> = [];

  /**
   * 学院下拉加载
   */
  // isLoading = false;

  /**
   * 添加专业
   */
  create() {
    this.professionListComponent.create();
  }

  /**
   * 刷新
   */
  reflesh() {
    this.professionListComponent.loadData();
  }

  /**
   * 查询
   */
  onSearch() {
    this.professionListComponent.loadData();
  }

  /**
   * 重置表单
   */
  onResetForm() {
    this.queryParams.academyId = null;
    this.queryParams.code = null;
    this.queryParams.name = null;
  }

  /**
   * 获取学院下拉
   */
  // getAcademyDropDownList() {
  //   this.academyService.findAllBySort('showOrder', 'asc').subscribe(data => {
  //     this.isLoading = false;
  //     this.academyList.forEach(academy => {
  //       // 删除与原有学院重复的学院
  //       data.splice(
  //         data.findIndex(item => item === academy),
  //         1,
  //       );
  //     });
  //     this.academyList = [...this.academyList, ...data];
  //   });
  // }

  ngOnInit() {
    // this.getAcademyDropDownList();
  }
}
